﻿using System;
using System.Collections.Generic;
using Internal.KuiHuaBaoDian.Services.Battle;
using Internal.KuiHuaBaoDian.Services.Battle.Data;
using KuiHuaBaoDian.Services.Battle.Entity;

namespace KuiHuaBaoDian.Services.Battle.Data {

    /// <summary>
    /// 战斗数据
    /// </summary>
    public interface IReadOnlyBattleData : IReadOnlyF64Data {

        new IBattleData AsReadWrite();

        /// <summary>
        /// 实体ID
        /// </summary>
        public BattleEntityInstanceID EntityInstanceID { get; }
    }

    /// <summary>
    /// 战斗数据
    /// </summary>
    public interface IValueChangedBattleData : IReadOnlyBattleData, IValueChangedF64Data {
    }

    /// <summary>
    /// 战斗数据
    /// </summary>
    public interface IBattleData : IValueChangedBattleData, IF64Data {
    }

    [Implement(typeof(IReadOnlyBattleData))]
    [Implement(typeof(IValueChangedBattleData))]
    [Implement(typeof(IBattleData))]
    public abstract class KHBD_BattleData : KHBD_Data<F64>, IBattleData, IReadOnlyBattleFusionData.IItem, IBattleDataInternal {

        public BattleEntityInstanceID EntityInstanceID { get; private set; }

        void IBattleDataInternal.EnableFilter(BattleEntityInstanceID entityInstanceID) {
            EntityInstanceID = entityInstanceID;
        }

        IBattleData IReadOnlyBattleData.AsReadWrite() => this;

        bool IReadOnlyBattleFusionData.IItem.ApplyFilter(IEnumerable<IReadOnlyBattleFusionData.IItem> owner, IReadOnlyCollection<IReadOnlyBattleFusionData.IItem> takedItems) {
            return (BattleService.Instance as IBattleServiceInternal).ApplyFusionDataItemFilter(owner, this, takedItems);
        }
    }
}

namespace Internal.KuiHuaBaoDian.Services.Battle.Data {

    public interface IBattleDataInternal {

        void EnableFilter(BattleEntityInstanceID entityInstanceID);
    }
}